package com.ruoyi.web.ydz.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.ydz.domain.JapanNews;
import com.ruoyi.web.ydz.service.IJapanNewsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 日本看病指南Controller
 * 
 * @author ruoyi
 * @date 2025-08-25
 */
@RestController
@RequestMapping("/ydz/japanNews")
public class JapanNewsController extends BaseController
{
    @Resource
    private IJapanNewsService japanNewsService;

    /**
     * 查询日本看病指南列表
     */
    @PreAuthorize("@ss.hasPermi('ydz:japanNews:list')")
    @GetMapping("/list")
    public TableDataInfo list(JapanNews japanNews)
    {
        startPage();
        List<JapanNews> list = japanNewsService.selectJapanNewsList(japanNews);
        return getDataTable(list);
    }

    /**
     * 导出日本看病指南列表
     */
    @PreAuthorize("@ss.hasPermi('ydz:japanNews:export')")
    @Log(title = "日本看病指南", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JapanNews japanNews)
    {
        List<JapanNews> list = japanNewsService.selectJapanNewsList(japanNews);
        ExcelUtil<JapanNews> util = new ExcelUtil<JapanNews>(JapanNews.class);
        util.exportExcel(response, list, "日本看病指南数据");
    }

    /**
     * 获取日本看病指南详细信息
     */
    @PreAuthorize("@ss.hasPermi('ydz:japanNews:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(japanNewsService.selectJapanNewsById(id));
    }

    /**
     * 新增日本看病指南
     */
    @PreAuthorize("@ss.hasPermi('ydz:japanNews:add')")
    @Log(title = "日本看病指南", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JapanNews japanNews)
    {
        return toAjax(japanNewsService.insertJapanNews(japanNews));
    }

    /**
     * 修改日本看病指南
     */
    @PreAuthorize("@ss.hasPermi('ydz:japanNews:edit')")
    @Log(title = "日本看病指南", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JapanNews japanNews)
    {
        return toAjax(japanNewsService.updateJapanNews(japanNews));
    }

    /**
     * 删除日本看病指南
     */
    @PreAuthorize("@ss.hasPermi('ydz:japanNews:remove')")
    @Log(title = "日本看病指南", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(japanNewsService.deleteJapanNewsByIds(ids));
    }

    @GetMapping(value = "/updateJapanNewsHis/{id}")
    public void updateJapanNewsHis(@PathVariable("id") Long id)
    {
        japanNewsService.updateJapanNewsHis(id);
    }

    @GetMapping("/getUpAndDown/{id}")
    public AjaxResult getUpAndDown(@PathVariable("id") Long id){
        return japanNewsService.getUpAndDown(id);
    }
}
